    <!--hidden first-->
    <?php echo form_open(base_url().'util/send_message'); ?>
    <div id="compose" style="display: none;">
            <div id="compose-window">
                <label class="kepada">Kepada:</label>   
                <input type="text" class="kepada" name="kepada" />
                <div class="clear"></div>
                <label>Subjek:</label>
                <input type="text" id="subjek" name="subjek"/>
                <label>Pesan:</label>
                <textarea id="isi" name="isi"></textarea>
                <div class="clear"></div>
                <input type="submit" value="Kirim" id="pesan-kirim" onclick="send()"/>
                <input type="button" value="Batal" id="pesan-batal" onclick="cancel()"/>
                <div class="clear"></div>
                <div id="error_message"></div>
            </div>
        </div>
    <?php echo form_close();?>


        <h1>HOME > PESAN</h1>
        <div id="message-menu">
            <ul>
                <li onclick="compose()" style="cursor: pointer;">BUAT PESAN</li>
                <li><a href="<?echo base_url().'member/inbox'?>">KOTAK MASUK <?if(count($unread) > 0){echo '('.count($unread).')';}?></li>
                <li><a href="<?echo base_url().'member/sent'?>">PESAN TERKIRIM</a></li>
            </ul>
        </div>
        <div id="message-list">
            <table>
                <?
                if($action == 0){
                echo '<tr>
                    <td>Dari</td>
                    <td>Subjek</td>
                </tr>';
                }elseif($action == 1){
                    echo '<tr>
                    <td>Kepada</td>
                    <td>Subjek</td>
                </tr>';
                }
                if($action == 0){
                    if(count($msg) == 0){
                        echo
                        '<tr>
                            <td>
                               No Message
                            </td>
                        </tr>';
                    }else{
                        for($i=0;$i<count($msg);$i++){
                            echo
                            '<tr>
                                <td>
                                   <a href="'.base_url().'member/view_msg/'.$msg[$i]['ID_MESSAGE'].'">'.$msg[$i]['NAME'].'</a>
                                </td>
                                <td>
                                    <a href="'.base_url().'member/view_msg/'.$msg[$i]['ID_MESSAGE'].'">'.$msg[$i]['SUBJECT'].'</a>
                                </td>
                            </tr>
                            ';
                        }
                    }
                }elseif ($action == 1) {
                    if(count($msg) == 0){
                        echo
                        '<tr>
                            <td>
                               No Message
                            </td>
                        </tr>';
                    }else{
                        for($i=0;$i<count($msg);$i++){
                            echo
                            '<tr>
                                <td>
                                   <a href="'.base_url().'member/view_sent/'.$msg[$i]['ID_MESSAGE'].'">'.$msg[$i]['NAME'].'</a>
                                </td>
                                <td>
                                    <a href="'.base_url().'member/view_sent/'.$msg[$i]['ID_MESSAGE'].'">'.$msg[$i]['SUBJECT'].'</a>
                                </td>
                            </tr>
                            ';
                        }
                    }
                }else{ //action = 3
                    echo 'Pengirim: '.$msg['NAME'].'<br/>'.'Subjek: '.$msg['SUBJECT'].'<br/>'.$msg['CONTENT'].'<br/>';
                    if($sent == 0){
                            echo '<form method="POST" action="'.base_url().'util/send_message">
                                <textarea id="reply" name="isi"></textarea>
                                <input type="hidden" name="subjek" value="'.$msg['SUBJECT'].'" />
                                <input type="hidden" name="kepada" value="'.$msg['NAME'].'" />
                                <input type="submit" value="Balas" />
                              </form>';
                    }
                }
                ?>
            </table>
        </div>
    </div>